<?xml version="1.0" encoding="utf-8" ?>

<cms:formdefinition
  xmlns="http://www.composite.net/ns/management/bindingforms/std.ui.controls.lib/1.0"
  xmlns:internal="http://www.composite.net/ns/management/bindingforms/internal.ui.controls.lib/1.0"
  xmlns:f="http://www.composite.net/ns/management/bindingforms/std.function.lib/1.0"
  xmlns:cms="http://www.composite.net/ns/management/bindingforms/1.0">

  <cms:bindings>
    <cms:binding name="Form" type="Composite.C1Console.Forms.IUiControl, Composite" />
    <cms:binding name="CustomToolbarItems" type="Composite.C1Console.Forms.IUiControl, Composite" optional="true" />
    <cms:binding name="SaveEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="SaveAndPublishEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="SaveAsEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="NextEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="PreviousEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="FinishEventHandler" type="System.EventHandler" optional="true" />
    <cms:binding name="CancelEventHandler" type="System.EventHandler" optional="true" />
  </cms:bindings>

  <cms:layout >
    <PlaceHolder>
      <internal:Toolbar>
        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="SaveEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <internal:SaveButton Label="${Composite.Management, Website.Forms.Administrative.AdministrativeTemplates.Document.LabelSave}">
              <internal:SaveButton.SaveEventHandler>                
                <cms:read source="SaveEventHandler" />
              </internal:SaveButton.SaveEventHandler>
              <internal:SaveButton.SaveAndPublishEventHandler>
                <cms:read source="SaveAndPublishEventHandler" />
              </internal:SaveButton.SaveAndPublishEventHandler>
            </internal:SaveButton>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>
<!--
        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="SaveAndPublishEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <ToolbarButton Label="Save and Publish">
              <ToolbarButton.ClickEventHandler>
                <cms:read source="SaveAndPublishEventHandler" />
              </ToolbarButton.ClickEventHandler>
            </ToolbarButton>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>
-->        

        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="SaveAsEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <internal:SaveAsButton Label="${Composite.Management, Website.Forms.Administrative.AdministrativeTemplates.Document.LabelSaveAs}">
              <internal:SaveAsButton.ClickEventHandler>
                <cms:read source="SaveAsEventHandler" />
              </internal:SaveAsButton.ClickEventHandler>
            </internal:SaveAsButton>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>


        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="PreviousEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <Text>PREVIOUS EVENTS NOT EXPECTED ON DOCUMENTS</Text>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>

        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="NextEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <Text>NEXT EVENTS NOT EXPECTED ON DOCUMENTS</Text>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>

        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="FinishEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <Text>FINISH EVENTS NOT EXPECTED ON DOCUMENTS</Text>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>

        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="CancelEventHandler" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <Text>CANCEL EVENTS NOT EXPECTED ON DOCUMENTS</Text>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>

        <f:NullCheck>
          <f:NullCheck.CheckValue>
            <cms:read source="CustomToolbarItems" />
          </f:NullCheck.CheckValue>
          <f:NullCheck.WhenNotNull>
            <f:Replicator>
              <cms:read source="CustomToolbarItems" />
            </f:Replicator>
          </f:NullCheck.WhenNotNull>
        </f:NullCheck>

      </internal:Toolbar>
      <internal:DocumentBody>

        <f:Replicator>
          <cms:read source="Form" />
        </f:Replicator>
      </internal:DocumentBody>
    </PlaceHolder>
  </cms:layout>
</cms:formdefinition>

